from flask import Flask, render_template
from flask_sqlalchemy import SQLAlchemy
from config import CONFIG
a = Flask(__name__)

sql = SQLAlchemy()

# 404
@a.errorhandler(404)
def miss(e):
    return render_template('other/404.html'), 404


def creat(are):
    a.config.from_object(CONFIG[are])
    sql.init_app(a)
    from app.views.index import index_blu
    from app.views.uitl import uitl_blu
    from app.views.user import user_blu
    # from app.views.passport import passport_blu
    # from app.views.user import user_blu
    # from app.views.news import news_blu
    # from app.views.admin import admin_blu
    # a.register_blueprint(passport_blu, url_prefix="/passport")
    a.register_blueprint(index_blu)
    a.register_blueprint(uitl_blu)
    a.register_blueprint(user_blu, url_prefix="/user")
    # a.register_blueprint(news_blu, url_prefix="/news")
    # a.register_blueprint(admin_blu, url_prefix="/admin")
    return a
